//
//  HBSignItemCell.m
//  HeartBeat
//
//  Created by karong on 2023/8/29.
//

#import "HBSignItemCell.h"
#import "HBSignModel.h"

@interface HBSignItemCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *dayLabel;
@property (weak, nonatomic) IBOutlet UIButton *signBtn;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet YYAnimatedImageView *gifAnimationView;
@end

@implementation HBSignItemCell
- (void)setDataWithObject:(HBSignModel *)object day:(NSInteger)day {
    self.dayLabel.text = SF(WSLocalized(@"第%ld天"), (long) object.days);
    [self setMainViewWithObject:object day:day];
    [self setRewardWithObject:object];
    if (self.gifAnimationView) {
        self.gifAnimationView.image = [YYImage imageNamed:@"sign.gif"];
    }
}

- (void)setMainViewWithObject:(HBSignModel *)object day:(NSInteger)day {
    UIColor * dayColor = UIColor.font_black_1A1A1A;
    NSString * imageStr = @"fl_lihe_h";
    if (object.days <= day) {
        dayColor = UIColor.font_gray_999999;
        imageStr = @"fl_lihe_b";
    }
    self.dayLabel.textColor = dayColor;
    self.imageView.image = IMG(imageStr);
}

- (void)setRewardWithObject:(HBSignModel *)object {
    self.titleLabel.text = SF(@"+%ld", (long)object.coins);
}

- (IBAction)signAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(signItemCellSignAction:)]) {
        [self.delegate signItemCellSignAction:self];
    }
}


@end
